package com.cloud.servicegreyrelease2.entity;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
/**
*
*  @author wugy
*/
public class GreySetting implements Serializable {

    private static final long serialVersionUID = 1626239460826L;


    /**
    * 主键
    * 主键自增ID
    * isNullAble:0
    */
    private Integer id;

    /**
    * 用户Id
    * isNullAble:0
    */
    private Integer userId;

    /**
    * 服务名
    * isNullAble:0
    */
    private String serviceName;

    /**
    * 服务版本号
    * isNullAble:0
    */
    private String version;

    /**
    * 启用状态
    * isNullAble:0,defaultVal:1
    */
    private Integer inUse;

    /**
    * 创建人Id
    * isNullAble:0
    */
    private Integer createUserId;

    /**
    * 创建时间
    * isNullAble:1,defaultVal:CURRENT_TIMESTAMP
    */
    private java.time.LocalDateTime createTime;


    public void setId(Integer id){this.id = id;}

    public Integer getId(){return this.id;}

    public void setUserId(Integer userId){this.userId = userId;}

    public Integer getUserId(){return this.userId;}

    public void setServiceName(String serviceName){this.serviceName = serviceName;}

    public String getServiceName(){return this.serviceName;}

    public void setVersion(String version){this.version = version;}

    public String getVersion(){return this.version;}

    public void setInUse(Integer inUse){this.inUse = inUse;}

    public Integer getInUse(){return this.inUse;}

    public void setCreateUserId(Integer createUserId){this.createUserId = createUserId;}

    public Integer getCreateUserId(){return this.createUserId;}

    public void setCreateTime(java.time.LocalDateTime createTime){this.createTime = createTime;}

    public java.time.LocalDateTime getCreateTime(){return this.createTime;}
    @Override
    public String toString() {
        return "GreySetting{" +
                "id='" + id + '\'' +
                "userId='" + userId + '\'' +
                "serviceName='" + serviceName + '\'' +
                "version='" + version + '\'' +
                "inUse='" + inUse + '\'' +
                "createUserId='" + createUserId + '\'' +
                "createTime='" + createTime + '\'' +
            '}';
    }

    public static Builder Build(){return new Builder();}

    public static ConditionBuilder ConditionBuild(){return new ConditionBuilder();}

    public static UpdateBuilder UpdateBuild(){return new UpdateBuilder();}

    public static QueryBuilder QueryBuild(){return new QueryBuilder();}

    public static class UpdateBuilder {

        private GreySetting set;

        private ConditionBuilder where;

        public UpdateBuilder set(GreySetting set){
            this.set = set;
            return this;
        }

        public GreySetting getSet(){
            return this.set;
        }

        public UpdateBuilder where(ConditionBuilder where){
            this.where = where;
            return this;
        }

        public ConditionBuilder getWhere(){
            return this.where;
        }

        public UpdateBuilder build(){
            return this;
        }
    }

    public static class QueryBuilder extends GreySetting{
        /**
        * 需要返回的列
        */
        private Map<String,Object> fetchFields;

        public Map<String,Object> getFetchFields(){return this.fetchFields;}

        private List<Integer> idList;

        public List<Integer> getIdList(){return this.idList;}

        private Integer idSt;

        private Integer idEd;

        public Integer getIdSt(){return this.idSt;}

        public Integer getIdEd(){return this.idEd;}

        private List<Integer> userIdList;

        public List<Integer> getUserIdList(){return this.userIdList;}

        private Integer userIdSt;

        private Integer userIdEd;

        public Integer getUserIdSt(){return this.userIdSt;}

        public Integer getUserIdEd(){return this.userIdEd;}

        private List<String> serviceNameList;

        public List<String> getServiceNameList(){return this.serviceNameList;}


        private List<String> fuzzyServiceName;

        public List<String> getFuzzyServiceName(){return this.fuzzyServiceName;}

        private List<String> rightFuzzyServiceName;

        public List<String> getRightFuzzyServiceName(){return this.rightFuzzyServiceName;}
        private List<String> versionList;

        public List<String> getVersionList(){return this.versionList;}


        private List<String> fuzzyVersion;

        public List<String> getFuzzyVersion(){return this.fuzzyVersion;}

        private List<String> rightFuzzyVersion;

        public List<String> getRightFuzzyVersion(){return this.rightFuzzyVersion;}
        private List<Integer> inUseList;

        public List<Integer> getInUseList(){return this.inUseList;}

        private Integer inUseSt;

        private Integer inUseEd;

        public Integer getInUseSt(){return this.inUseSt;}

        public Integer getInUseEd(){return this.inUseEd;}

        private List<Integer> createUserIdList;

        public List<Integer> getCreateUserIdList(){return this.createUserIdList;}

        private Integer createUserIdSt;

        private Integer createUserIdEd;

        public Integer getCreateUserIdSt(){return this.createUserIdSt;}

        public Integer getCreateUserIdEd(){return this.createUserIdEd;}

        private List<java.time.LocalDateTime> createTimeList;

        public List<java.time.LocalDateTime> getCreateTimeList(){return this.createTimeList;}

        private java.time.LocalDateTime createTimeSt;

        private java.time.LocalDateTime createTimeEd;

        public java.time.LocalDateTime getCreateTimeSt(){return this.createTimeSt;}

        public java.time.LocalDateTime getCreateTimeEd(){return this.createTimeEd;}

        private QueryBuilder (){
            this.fetchFields = new HashMap<>();
        }

        public QueryBuilder idBetWeen(Integer idSt,Integer idEd){
            this.idSt = idSt;
            this.idEd = idEd;
            return this;
        }

        public QueryBuilder idGreaterEqThan(Integer idSt){
            this.idSt = idSt;
            return this;
        }
        public QueryBuilder idLessEqThan(Integer idEd){
            this.idEd = idEd;
            return this;
        }


        public QueryBuilder id(Integer id){
            setId(id);
            return this;
        }

        public QueryBuilder idList(Integer ... id){
            this.idList = solveNullList(id);
            return this;
        }

        public QueryBuilder idList(List<Integer> id){
            this.idList = id;
            return this;
        }

        public QueryBuilder fetchId(){
            setFetchFields("fetchFields","id");
            return this;
        }

        public QueryBuilder excludeId(){
            setFetchFields("excludeFields","id");
            return this;
        }

        public QueryBuilder userIdBetWeen(Integer userIdSt,Integer userIdEd){
            this.userIdSt = userIdSt;
            this.userIdEd = userIdEd;
            return this;
        }

        public QueryBuilder userIdGreaterEqThan(Integer userIdSt){
            this.userIdSt = userIdSt;
            return this;
        }
        public QueryBuilder userIdLessEqThan(Integer userIdEd){
            this.userIdEd = userIdEd;
            return this;
        }


        public QueryBuilder userId(Integer userId){
            setUserId(userId);
            return this;
        }

        public QueryBuilder userIdList(Integer ... userId){
            this.userIdList = solveNullList(userId);
            return this;
        }

        public QueryBuilder userIdList(List<Integer> userId){
            this.userIdList = userId;
            return this;
        }

        public QueryBuilder fetchUserId(){
            setFetchFields("fetchFields","userId");
            return this;
        }

        public QueryBuilder excludeUserId(){
            setFetchFields("excludeFields","userId");
            return this;
        }

        public QueryBuilder fuzzyServiceName (List<String> fuzzyServiceName){
            this.fuzzyServiceName = fuzzyServiceName;
            return this;
        }

        public QueryBuilder fuzzyServiceName (String ... fuzzyServiceName){
            this.fuzzyServiceName = solveNullList(fuzzyServiceName);
            return this;
        }

        public QueryBuilder rightFuzzyServiceName (List<String> rightFuzzyServiceName){
            this.rightFuzzyServiceName = rightFuzzyServiceName;
            return this;
        }

        public QueryBuilder rightFuzzyServiceName (String ... rightFuzzyServiceName){
            this.rightFuzzyServiceName = solveNullList(rightFuzzyServiceName);
            return this;
        }

        public QueryBuilder serviceName(String serviceName){
            setServiceName(serviceName);
            return this;
        }

        public QueryBuilder serviceNameList(String ... serviceName){
            this.serviceNameList = solveNullList(serviceName);
            return this;
        }

        public QueryBuilder serviceNameList(List<String> serviceName){
            this.serviceNameList = serviceName;
            return this;
        }

        public QueryBuilder fetchServiceName(){
            setFetchFields("fetchFields","serviceName");
            return this;
        }

        public QueryBuilder excludeServiceName(){
            setFetchFields("excludeFields","serviceName");
            return this;
        }

        public QueryBuilder fuzzyVersion (List<String> fuzzyVersion){
            this.fuzzyVersion = fuzzyVersion;
            return this;
        }

        public QueryBuilder fuzzyVersion (String ... fuzzyVersion){
            this.fuzzyVersion = solveNullList(fuzzyVersion);
            return this;
        }

        public QueryBuilder rightFuzzyVersion (List<String> rightFuzzyVersion){
            this.rightFuzzyVersion = rightFuzzyVersion;
            return this;
        }

        public QueryBuilder rightFuzzyVersion (String ... rightFuzzyVersion){
            this.rightFuzzyVersion = solveNullList(rightFuzzyVersion);
            return this;
        }

        public QueryBuilder version(String version){
            setVersion(version);
            return this;
        }

        public QueryBuilder versionList(String ... version){
            this.versionList = solveNullList(version);
            return this;
        }

        public QueryBuilder versionList(List<String> version){
            this.versionList = version;
            return this;
        }

        public QueryBuilder fetchVersion(){
            setFetchFields("fetchFields","version");
            return this;
        }

        public QueryBuilder excludeVersion(){
            setFetchFields("excludeFields","version");
            return this;
        }

        public QueryBuilder inUseBetWeen(Integer inUseSt,Integer inUseEd){
            this.inUseSt = inUseSt;
            this.inUseEd = inUseEd;
            return this;
        }

        public QueryBuilder inUseGreaterEqThan(Integer inUseSt){
            this.inUseSt = inUseSt;
            return this;
        }
        public QueryBuilder inUseLessEqThan(Integer inUseEd){
            this.inUseEd = inUseEd;
            return this;
        }


        public QueryBuilder inUse(Integer inUse){
            setInUse(inUse);
            return this;
        }

        public QueryBuilder inUseList(Integer ... inUse){
            this.inUseList = solveNullList(inUse);
            return this;
        }

        public QueryBuilder inUseList(List<Integer> inUse){
            this.inUseList = inUse;
            return this;
        }

        public QueryBuilder fetchInUse(){
            setFetchFields("fetchFields","inUse");
            return this;
        }

        public QueryBuilder excludeInUse(){
            setFetchFields("excludeFields","inUse");
            return this;
        }

        public QueryBuilder createUserIdBetWeen(Integer createUserIdSt,Integer createUserIdEd){
            this.createUserIdSt = createUserIdSt;
            this.createUserIdEd = createUserIdEd;
            return this;
        }

        public QueryBuilder createUserIdGreaterEqThan(Integer createUserIdSt){
            this.createUserIdSt = createUserIdSt;
            return this;
        }
        public QueryBuilder createUserIdLessEqThan(Integer createUserIdEd){
            this.createUserIdEd = createUserIdEd;
            return this;
        }


        public QueryBuilder createUserId(Integer createUserId){
            setCreateUserId(createUserId);
            return this;
        }

        public QueryBuilder createUserIdList(Integer ... createUserId){
            this.createUserIdList = solveNullList(createUserId);
            return this;
        }

        public QueryBuilder createUserIdList(List<Integer> createUserId){
            this.createUserIdList = createUserId;
            return this;
        }

        public QueryBuilder fetchCreateUserId(){
            setFetchFields("fetchFields","createUserId");
            return this;
        }

        public QueryBuilder excludeCreateUserId(){
            setFetchFields("excludeFields","createUserId");
            return this;
        }

        public QueryBuilder createTimeBetWeen(java.time.LocalDateTime createTimeSt,java.time.LocalDateTime createTimeEd){
            this.createTimeSt = createTimeSt;
            this.createTimeEd = createTimeEd;
            return this;
        }

        public QueryBuilder createTimeGreaterEqThan(java.time.LocalDateTime createTimeSt){
            this.createTimeSt = createTimeSt;
            return this;
        }
        public QueryBuilder createTimeLessEqThan(java.time.LocalDateTime createTimeEd){
            this.createTimeEd = createTimeEd;
            return this;
        }


        public QueryBuilder createTime(java.time.LocalDateTime createTime){
            setCreateTime(createTime);
            return this;
        }

        public QueryBuilder createTimeList(java.time.LocalDateTime ... createTime){
            this.createTimeList = solveNullList(createTime);
            return this;
        }

        public QueryBuilder createTimeList(List<java.time.LocalDateTime> createTime){
            this.createTimeList = createTime;
            return this;
        }

        public QueryBuilder fetchCreateTime(){
            setFetchFields("fetchFields","createTime");
            return this;
        }

        public QueryBuilder excludeCreateTime(){
            setFetchFields("excludeFields","createTime");
            return this;
        }
        private <T>List<T> solveNullList(T ... objs){
            if (objs != null){
            List<T> list = new ArrayList<>();
                for (T item : objs){
                    if (item != null){
                        list.add(item);
                    }
                }
                return list;
            }
            return null;
        }

        public QueryBuilder fetchAll(){
            this.fetchFields.put("AllFields",true);
            return this;
        }

        public QueryBuilder addField(String ... fields){
            List<String> list = new ArrayList<>();
            if (fields != null){
                for (String field : fields){
                    list.add(field);
                }
            }
            this.fetchFields.put("otherFields",list);
            return this;
        }
        @SuppressWarnings("unchecked")
        private void setFetchFields(String key,String val){
            Map<String,Boolean> fields= (Map<String, Boolean>) this.fetchFields.get(key);
            if (fields == null){
                fields = new HashMap<>();
            }
            fields.put(val,true);
            this.fetchFields.put(key,fields);
        }

        public GreySetting build(){return this;}
    }


    public static class ConditionBuilder{
        private List<Integer> idList;

        public List<Integer> getIdList(){return this.idList;}

        private Integer idSt;

        private Integer idEd;

        public Integer getIdSt(){return this.idSt;}

        public Integer getIdEd(){return this.idEd;}

        private List<Integer> userIdList;

        public List<Integer> getUserIdList(){return this.userIdList;}

        private Integer userIdSt;

        private Integer userIdEd;

        public Integer getUserIdSt(){return this.userIdSt;}

        public Integer getUserIdEd(){return this.userIdEd;}

        private List<String> serviceNameList;

        public List<String> getServiceNameList(){return this.serviceNameList;}


        private List<String> fuzzyServiceName;

        public List<String> getFuzzyServiceName(){return this.fuzzyServiceName;}

        private List<String> rightFuzzyServiceName;

        public List<String> getRightFuzzyServiceName(){return this.rightFuzzyServiceName;}
        private List<String> versionList;

        public List<String> getVersionList(){return this.versionList;}


        private List<String> fuzzyVersion;

        public List<String> getFuzzyVersion(){return this.fuzzyVersion;}

        private List<String> rightFuzzyVersion;

        public List<String> getRightFuzzyVersion(){return this.rightFuzzyVersion;}
        private List<Integer> inUseList;

        public List<Integer> getInUseList(){return this.inUseList;}

        private Integer inUseSt;

        private Integer inUseEd;

        public Integer getInUseSt(){return this.inUseSt;}

        public Integer getInUseEd(){return this.inUseEd;}

        private List<Integer> createUserIdList;

        public List<Integer> getCreateUserIdList(){return this.createUserIdList;}

        private Integer createUserIdSt;

        private Integer createUserIdEd;

        public Integer getCreateUserIdSt(){return this.createUserIdSt;}

        public Integer getCreateUserIdEd(){return this.createUserIdEd;}

        private List<java.time.LocalDateTime> createTimeList;

        public List<java.time.LocalDateTime> getCreateTimeList(){return this.createTimeList;}

        private java.time.LocalDateTime createTimeSt;

        private java.time.LocalDateTime createTimeEd;

        public java.time.LocalDateTime getCreateTimeSt(){return this.createTimeSt;}

        public java.time.LocalDateTime getCreateTimeEd(){return this.createTimeEd;}


        public ConditionBuilder idBetWeen(Integer idSt,Integer idEd){
            this.idSt = idSt;
            this.idEd = idEd;
            return this;
        }

        public ConditionBuilder idGreaterEqThan(Integer idSt){
            this.idSt = idSt;
            return this;
        }
        public ConditionBuilder idLessEqThan(Integer idEd){
            this.idEd = idEd;
            return this;
        }


        public ConditionBuilder idList(Integer ... id){
            this.idList = solveNullList(id);
            return this;
        }

        public ConditionBuilder idList(List<Integer> id){
            this.idList = id;
            return this;
        }

        public ConditionBuilder userIdBetWeen(Integer userIdSt,Integer userIdEd){
            this.userIdSt = userIdSt;
            this.userIdEd = userIdEd;
            return this;
        }

        public ConditionBuilder userIdGreaterEqThan(Integer userIdSt){
            this.userIdSt = userIdSt;
            return this;
        }
        public ConditionBuilder userIdLessEqThan(Integer userIdEd){
            this.userIdEd = userIdEd;
            return this;
        }


        public ConditionBuilder userIdList(Integer ... userId){
            this.userIdList = solveNullList(userId);
            return this;
        }

        public ConditionBuilder userIdList(List<Integer> userId){
            this.userIdList = userId;
            return this;
        }

        public ConditionBuilder fuzzyServiceName (List<String> fuzzyServiceName){
            this.fuzzyServiceName = fuzzyServiceName;
            return this;
        }

        public ConditionBuilder fuzzyServiceName (String ... fuzzyServiceName){
            this.fuzzyServiceName = solveNullList(fuzzyServiceName);
            return this;
        }

        public ConditionBuilder rightFuzzyServiceName (List<String> rightFuzzyServiceName){
            this.rightFuzzyServiceName = rightFuzzyServiceName;
            return this;
        }

        public ConditionBuilder rightFuzzyServiceName (String ... rightFuzzyServiceName){
            this.rightFuzzyServiceName = solveNullList(rightFuzzyServiceName);
            return this;
        }

        public ConditionBuilder serviceNameList(String ... serviceName){
            this.serviceNameList = solveNullList(serviceName);
            return this;
        }

        public ConditionBuilder serviceNameList(List<String> serviceName){
            this.serviceNameList = serviceName;
            return this;
        }

        public ConditionBuilder fuzzyVersion (List<String> fuzzyVersion){
            this.fuzzyVersion = fuzzyVersion;
            return this;
        }

        public ConditionBuilder fuzzyVersion (String ... fuzzyVersion){
            this.fuzzyVersion = solveNullList(fuzzyVersion);
            return this;
        }

        public ConditionBuilder rightFuzzyVersion (List<String> rightFuzzyVersion){
            this.rightFuzzyVersion = rightFuzzyVersion;
            return this;
        }

        public ConditionBuilder rightFuzzyVersion (String ... rightFuzzyVersion){
            this.rightFuzzyVersion = solveNullList(rightFuzzyVersion);
            return this;
        }

        public ConditionBuilder versionList(String ... version){
            this.versionList = solveNullList(version);
            return this;
        }

        public ConditionBuilder versionList(List<String> version){
            this.versionList = version;
            return this;
        }

        public ConditionBuilder inUseBetWeen(Integer inUseSt,Integer inUseEd){
            this.inUseSt = inUseSt;
            this.inUseEd = inUseEd;
            return this;
        }

        public ConditionBuilder inUseGreaterEqThan(Integer inUseSt){
            this.inUseSt = inUseSt;
            return this;
        }
        public ConditionBuilder inUseLessEqThan(Integer inUseEd){
            this.inUseEd = inUseEd;
            return this;
        }


        public ConditionBuilder inUseList(Integer ... inUse){
            this.inUseList = solveNullList(inUse);
            return this;
        }

        public ConditionBuilder inUseList(List<Integer> inUse){
            this.inUseList = inUse;
            return this;
        }

        public ConditionBuilder createUserIdBetWeen(Integer createUserIdSt,Integer createUserIdEd){
            this.createUserIdSt = createUserIdSt;
            this.createUserIdEd = createUserIdEd;
            return this;
        }

        public ConditionBuilder createUserIdGreaterEqThan(Integer createUserIdSt){
            this.createUserIdSt = createUserIdSt;
            return this;
        }
        public ConditionBuilder createUserIdLessEqThan(Integer createUserIdEd){
            this.createUserIdEd = createUserIdEd;
            return this;
        }


        public ConditionBuilder createUserIdList(Integer ... createUserId){
            this.createUserIdList = solveNullList(createUserId);
            return this;
        }

        public ConditionBuilder createUserIdList(List<Integer> createUserId){
            this.createUserIdList = createUserId;
            return this;
        }

        public ConditionBuilder createTimeBetWeen(java.time.LocalDateTime createTimeSt,java.time.LocalDateTime createTimeEd){
            this.createTimeSt = createTimeSt;
            this.createTimeEd = createTimeEd;
            return this;
        }

        public ConditionBuilder createTimeGreaterEqThan(java.time.LocalDateTime createTimeSt){
            this.createTimeSt = createTimeSt;
            return this;
        }
        public ConditionBuilder createTimeLessEqThan(java.time.LocalDateTime createTimeEd){
            this.createTimeEd = createTimeEd;
            return this;
        }


        public ConditionBuilder createTimeList(java.time.LocalDateTime ... createTime){
            this.createTimeList = solveNullList(createTime);
            return this;
        }

        public ConditionBuilder createTimeList(List<java.time.LocalDateTime> createTime){
            this.createTimeList = createTime;
            return this;
        }

        private <T>List<T> solveNullList(T ... objs){
            if (objs != null){
            List<T> list = new ArrayList<>();
                for (T item : objs){
                    if (item != null){
                        list.add(item);
                    }
                }
                return list;
            }
            return null;
        }

        public ConditionBuilder build(){return this;}
    }

    public static class Builder {

        private GreySetting obj;

        public Builder(){
            this.obj = new GreySetting();
        }

        public Builder id(Integer id){
            this.obj.setId(id);
            return this;
        }
        public Builder userId(Integer userId){
            this.obj.setUserId(userId);
            return this;
        }
        public Builder serviceName(String serviceName){
            this.obj.setServiceName(serviceName);
            return this;
        }
        public Builder version(String version){
            this.obj.setVersion(version);
            return this;
        }
        public Builder inUse(Integer inUse){
            this.obj.setInUse(inUse);
            return this;
        }
        public Builder createUserId(Integer createUserId){
            this.obj.setCreateUserId(createUserId);
            return this;
        }
        public Builder createTime(java.time.LocalDateTime createTime){
            this.obj.setCreateTime(createTime);
            return this;
        }
        public GreySetting build(){return obj;}
    }

}
